cmake_minimum_required(VERSION 2.8)

project(ICP)
set(CMAKE_BUILD_TYPE "Debug")
set( CMAKE_CXX_FLAGS "-O3" )

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

find_package(Ceres REQUIRED)
Find_Package(G2O REQUIRED)
Find_Package(Eigen3 REQUIRED)
Find_Package(Cholmod REQUIRED)

#opencv
find_package( OpenCV 3.1 REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
SET(G2O_LIBS g2o_cli g2o_ext_freeglut_minimal g2o_simulator g2o_solver_slam2d_linear 
    g2o_types_icp g2o_types_slam2d g2o_types_sba g2o_types_slam3d g2o_core g2o_interface 
    g2o_solver_csparse g2o_solver_structure_only g2o_csparse_extension g2o_opengl_helper g2o_solver_dense 
    g2o_stuff g2o_types_sclam2d g2o_parser g2o_solver_pcg g2o_types_data g2o_types_sim3 cxsparse )


include_directories(${EIGEN3_INCLUDE_DIR} ${CHOLMOD_INCLUDE_DIR} ${CERES_INCLUDE_DIRS} ) 


message("find g2o libraries in: " ${G2O_INCLUDE_DIR})
message("find g2o lib in " ${G2O_LIBS})
message("find cholmod in " ${CHOLMOD_INCLUDE_DIR})
message("find ceres in " ${CERES_INCLUDE_DIR})
message("find opencv in " ${OpenCV_INCLUDE_DIRS})


add_library(icp ICP.cpp)
add_executable(fortest test.cpp)
add_executable(main main.cpp)
target_link_libraries(main ${G2O_LIBS} ${CHOLMOD_LIBRARIES} ${CERES_LIBRARIES} ${OpenCV_LIBS} icp)
target_link_libraries(icp ${G2O_LIBS} ${CHOLMOD_LIBRARIES} ${CERES_LIBRARIES} ${OpenCV_LIBS})
target_link_libraries(fortest ${G2O_LIBS} ${CHOLMOD_LIBRARIES} ${CERES_LIBRARIES} ${OpenCV_LIBS} icp)
